<extend name="Index/index" />
<block name="center">
<div class="col-lg-12">
    <div class="portlet box portlet-blue">
        <div class="portlet-header">
            <div class="caption">添加产品</div>
            <div class="tools"><i class="fa fa-chevron-up"></i><i class="fa fa-cog" data-target="#modal-config" data-toggle="modal"></i><i class="fa fa-refresh"></i><i class="fa fa-times"></i>
            </div>
        </div>
        <div class="portlet-body">
            <form class="form-horizontal" role="form" action="{:U('Admin/Foods/insert')}" method="post" enctype="multipart/form-data" >
                <div class="row">
                    <div class="col-md-6" style="width:100%;">
                        <div class="form-group" style="">
                            <label class="col-md-3 control-label" >产品名称</label>
                            <div class="col-md-9" style="">
                                <div style="float:left"><input type="text" class="form-control" placeholder="名称不能为空" name="name" id="fname" style="width:300px;"></div><div id="foodsname" style="float:left;margin-top:10px;" error="名称不能为空"></div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label" >产品价格</label>
                            <div class="col-md-9">
                                <div style="float:left"><input type="text" style="width:300px;" class="form-control" placeholder="价格不能为空且只能为数字" name="price" id="price"></div><div id="foodsprice" style="float:left;margin-top:10px;" error="价格不能为空" errornum="价格只能为数字"></div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label">所属分类</label>
                            <div class="col-md-9">
                                <select class="form-control" name="cid" style="width:300px;">
                                	<foreach name="cinfo" item="vo">
                                    	<option value="{$vo['id']}">{$vo['cname']}</option>
                                    </foreach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label" >起批量</label>
                            <div class="col-md-9">
                                <div style="float:left"><input type="text" style="width:300px;" class="form-control" name="number" id="number"></div>
                            </div>
                        </div>
                         <div class="form-group">
                            <label class="col-md-3 control-label" >规格</label>
                            <div class="col-md-9">
                                <div style="float:left"><input type="text" style="width:300px;" class="form-control" name="Specifications" id="Specifications"></div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label" for="exampleInputFile">产品图片</label>
                            <div class="col-md-9">
                                <input type="file" id="exampleInputFile" name="fpic">
                                <p class="help-block">请上传格式为:jpg png jpeg...的图片</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label">产品介绍</label>
                            <div class="col-md-9">
                                <textarea class="form-control" rows="3" name="fcontent" style="width:300px;"></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            
                           <div class="form-actions">
	                			<div class="col-md-offset-3 col-md-9">
		                    		<button type="submit" class="btn btn-primary">添加</button>&nbsp;
		                    		<button type="reset" class="btn btn-green">重置</button>
	                			</div>
	            			</div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript" src="__PUBLIC__/js/jquery-1.8.3.min.js"></script>

<script type="text/javascript">
$(function(){
	var statu = false;
	$('#fname').blur(function(){
		//获取值
		var v = $(this).val();
		// alert(v);
		if(v == ''){
			$(this).css('border','1px solid red');
            //获取值
            var fv = $('#foodsname').attr('error');
            $('#foodsname').html(fv).css('color','red');
			statu = false;
		}else{
			$(this).css('border','1px solid green');
            $('#foodsname').html('√').css('color','green');

			statu = true;
		}
	})

	$('#price').blur(function(){
		//获取值
		var v = $(this).val();
		// alert(v);
		if(v == ''){
			$(this).css('border','1px solid red');
            //获取
            var error = $('#foodsprice').attr('error');
            $('#foodsprice').html(error).css('color','red');
			statu = false;
		}else{
			
			$(this).css('border','1px solid green');
            $('#foodsprice').html('√').css('color','green');
			statu = true;
			}
		}
	})

	$('form').submit(function(){
		$('input').trigger('blur');
		if(statu == true){
			return true
		}else{
			return false;
		}
	})
})

	
</script>
</block>